#include "tou.h"
#include "input_library.h"
#include "detectionAssist.h" 

int denglu(BUF *BF)
{
    //用户信息结构体
    USERMES *usermes=(USERMES*)BF->buf;    
    int time=3;  //输错计数time
    //system("clear");                         //清屏
    do//do~while循环
    { 
        printf("账号:");
        scanf("%s",usermes->AccountNumber);
        getchar();
        passInputTwo(usermes->Password,1);                //使用普通密码输入
        int ret=Detection(BF);
        if(ret==1)
        {
            printf("登陆成功\n");
            return 1;
        }
        else if(ret==0)
        {
            time--;
            memset(usermes->AccountNumber,0,20);      //刷新存储的账号密码
            memset(usermes->Password,0,20);
            BF->choice=LOGIN;                           //重新至为LOGIN
            if(time>1) printf("账号密码错误，你还有%d次输入机会!\n",time);    //报错提示一共三次机会
            else if(time==1) printf("您还有最后%d次机会！\n",time);
            else printf("您尝试过多请稍后再尝试。\n");            
        }
    }
    while(time>0);
    return 0;
}